package com.alex.woqu;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.Button;

public class TabButton extends Button{
	
	private int normal_bg_res;
	private int selected_bg_res;

	public TabButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		
		TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TabButton);
		normal_bg_res = array.getResourceId(R.styleable.TabButton_normal_bg_res,0 );
		selected_bg_res = array.getResourceId(R.styleable.TabButton_selected_bg_res, 0);
		
		array.recycle();
	}

	public TabButton(Context context) {
		super(context);
	}

	public void setSelected(boolean selected){
		if(selected){
			setBackgroundResource(selected_bg_res);
			setTextColor(Color.WHITE);
		}else{
			setBackgroundResource(normal_bg_res);
			setTextColor(Color.GRAY);
		}
	}

}
